home *** CD-ROM | disk | FTP | other *** search
- Option Explicit
-
- ' Number of children
- Global ggNumChildren As Integer
-
- Function FileSaveAs ()
- Dim Msg, Answer
-
- FileSaveAs = True
-
- If ggNumChildren = 0 Then
- FileSaveAs = False
- Exit Function
- End If
-
-
-
- ' Set an error trap to detect the clicking
- ' of the Cancel key of the Save As dialog box.
- On Error GoTo SaveAsError
-
- ' Fill the items of the File Type list box of
- ' the Open dialog box.
- frmMultipad.CMDialog1.Filter = "All Files (*.*) |*.* |Text Files (*.txt)|*.txt|DOS Batch Files (*.bat)|*.bat"
-
- ' Set the default File Type to TXT files (*.txt).
- frmMultipad.CMDialog1.FilterIndex = 2
-
- ' Display the Save As dialog box.
- frmMultipad.CMDialog1.Action = 2
-
- ' Remove the error trap.
- On Error GoTo 0
-
- ' If the file specified by the user exists, and its
- ' size is not zero, ask the user if to overwrite it.
- If Dir(frmMultipad.CMDialog1.Filename) <> "" Then
- Msg = frmMultipad.CMDialog1.Filename + Chr(13)
- Msg = Msg + "This file already exists." + Chr(13) + Chr(13)
- Msg = Msg + "Replace existing file?"
- Answer = MsgBox(Msg, MB_ICONEXCLAMATION + MB_YESNO, "Multipad")
- If Answer = IDNO Then
- FileSaveAs = False
- Exit Function
- End If
- End If
-
- ' Set mouse cursor to hourglass.
- frmMultipad.ActiveForm.MousePointer = 11
-
- ' Change the FileName to the filename that
- ' the user selected, and issue a Save command.
- frmMultipad.ActiveForm.lblFilename.Caption = frmMultipad.CMDialog1.Filename
- SaveFile
-
- ' Set mouse cursor to default.
- frmMultipad.ActiveForm.MousePointer = 0
-
- ' Reset the chkFileHasChanged flag.
- frmMultipad.ActiveForm.chkFileHasChanged = False
-
- ' Set the title of the child window.
- frmMultipad.ActiveForm.Caption = frmMultipad.CMDialog1.Filetitle
-
-
- ' Exit the procedure.
- Exit Function
-
- SaveAsError:
- ' The user clicked the Cancel button.
- FileSaveAs = False
- Exit Function
-
- End Function
-
- Sub SaveFile ()
-
- Dim FileNum
-
- If ggNumChildren = 0 Then
- Exit Sub
- End If
-
-
-
-
- ' Get a free file number
- FileNum = FreeFile
-
- ' Open the file
- Open frmMultipad.ActiveForm.lblFilename.Caption For Output As FileNum
-
- ' Write the contents of the text file into the file
- Print #FileNum, frmMultipad.ActiveForm.txtDocument.Text
-
- ' Close the file
- Close FileNum
-
- frmMultipad.ActiveForm.chkFileHasChanged.Value = 0
-
- End Sub
-
-